import 'package:flutter/material.dart';
import 'package:flutter_levin/config/router_manager.dart';
import 'package:flutter_levin/config/storage_manager.dart';
import 'package:flutter_levin/config/ui_adapter_config.dart';
import 'package:oktoast/oktoast.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import 'config/router_manager.dart' as RouterManager;

void main() async {
  var widgetsBinding = InnerWidgetsFlutterBinding.ensureInitialized();

  await StorageManager.init();
  widgetsBinding
    ..attachRootWidget(MyApp())
    ..scheduleForcedFrame();
  // ToolbarUtils.setBarStatus(true);
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return OKToast(
      child: RefreshConfiguration(
        hideFooterWhenNotFull: true,
        headerBuilder: () => ClassicHeader(
          releaseText: '松开刷新',
          refreshingText: '正在加载...',
          failedText: '加载失败!!!',
          completeText: '加载完成',
          idleText: '下拉刷新',
        ),
        footerBuilder: () => ClassicFooter(
          noDataText: '我是有底线的~',
          loadingText: '正在加载',
          failedText: '加载失败!!!',
          idleText: '上拉加载更多',
          canLoadingText: '松开开始加载',
        ),
        child: MaterialApp(
          title: 'flutter levin',
          debugShowCheckedModeBanner: false,
          darkTheme: ThemeData(
              //primarySwatch: Colors.black,
              brightness: Brightness.light,
              primaryColor: Colors.black,
              primaryColorDark: Colors.black,
              accentColor: Colors.white,
              scaffoldBackgroundColor: Colors.black26,
              backgroundColor: Colors.black26,
              textTheme: TextTheme(subtitle1: TextStyle(color: Colors.black))),
          theme: ThemeData(
            //primarySwatch: Colors.white,
            brightness: Brightness.dark,
            primaryColor: Colors.white,
            primaryColorDark: Colors.white,
            accentColor: Colors.black38,
            scaffoldBackgroundColor: Colors.white70,
            backgroundColor: Colors.white70,
          ),
          themeMode: ThemeMode.system,
          onGenerateRoute: RouterManager.Router.generateRouter,
          initialRoute: RouteName.splash,
        ),
      ),
    );
  }
}
